Skip to content

update imagemagick to handle images types#2989

Open
alzamer2 wants to merge 22 commits into
dazedcat19:masterfrom
alzamer2:update-imagemagick-to-handle-images-types
Open

update imagemagick to handle images types#2989
alzamer2 wants to merge 22 commits into
dazedcat19:masterfrom
alzamer2:update-imagemagick-to-handle-images-types

Conversation

@alzamer2

Copy link
Copy Markdown

now any type that imagemagick can handle FMD2 can download it and if selected can convert to

alzamer2 added 22 commits May 17, 2026 09:50
now any type that imagemagick  can handle FMD2 can download it and if selected can convert to
AVIF Fix Summary
Root cause: AVIFCheckImageStream in ImgInfos.pas was reading bytes 0-3 expecting 'ftyp', but in AVIF/ISO BMFF files:
-
Bytes 0-3 = box size (binary integer, e.g. 0x00000018)
-
Bytes 4-7 = 'ftyp' magic
-
Bytes 8-11 = major brand (avif, avis, avio, mif1, msf1)
Fixes applied:
1.
ImgInfos.pas - AVIFCheckImageStream: Now correctly seeks to byte 4 to read 'ftyp', then reads major brand at byte 8. Also added support for avio, mif1, msf1 brands.
2.
uBaseUnit.pas - SaveImageStreamToFile: Added ExtFromContentType() helper that detects format from HTTP Content-Type header (e.g. image/avif → .avif). When stream-based detection fails, falls back to Content-Type before giving up.
fix coverlink avif error
1.update image magick to use dll
2.make when using image magickto convert images, ited download image to memoery> convertit> save it
3.include image magick dll in dist folder
4.now image cover support animated images (avif, gif, apng, webp, and tif/tiff)
add 'PNG','JXL','GIF','BMP','WEBP','TIF' to magick converting combobox
clean some debeging logger
…e tif with avif in save to.

[x] convert skiping.
[x] replace tif with avif in save to.
[x] add animated jxl to image info cover.
unlink libwebp.dll
you can now remove it from dist
fix fmd_magic
fix not loading dll if the imagemagic is not installed in system
add task monitor
this monitor will tell what each task thread is doing in real time
remove imagemagick "image compression type" option

@Slasar41 Slasar41 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all xml files and unnecessary dll in the coders folder.

FLastError := '';
DllName := 'CORE_RL_MagickWand_.dll';

SearchPath := ExtractFilePath(ParamStr(0)) + 'ImageMagick_dependency\';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to just imagemagick to match other folders.

Comment on lines 385 to 394
Paths := [
'C:\Program Files\ImageMagick\',
'C:\Program Files (x86)\ImageMagick\',
'C:\Program Files\ImageMagick-6.*.*\',
'C:\Program Files (x86)\ImageMagick-6.*.*\',
'C:\Program Files\ImageMagick-7.*.*\',
'C:\Program Files (x86)\ImageMagick-7.*.*\',
'C:\imagemagick\',
GetCurrentDir + '\'
'C:\Program Files\ImageMagick-7.1.2-Q16',
'C:\Program Files\ImageMagick-7.1.1-Q16',
'C:\Program Files\ImageMagick-7.1.0-Q16',
'C:\Program Files\ImageMagick-7.0.11-Q16',
'C:\Program Files\ImageMagick-7.0.10-Q16',
'C:\Program Files\ImageMagick-6.9.12-Q16',
'C:\Program Files (x86)\ImageMagick-7.1.2-Q16',
'C:\Program Files (x86)\ImageMagick-7.1.1-Q16'
];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Comment on lines 406 to 425
Reg := TRegistry.Create(KEY_READ);
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('SOFTWARE\ImageMagick\Current', False) or
Reg.OpenKey('SOFTWARE\WOW6432Node\ImageMagick\Current', False) then
if Reg.OpenKeyReadOnly('SOFTWARE\Imagemagick\7') or Reg.OpenKeyReadOnly('SOFTWARE\Wow6432Node\Imagemagick\7') then
begin
FMagickPath := IncludeTrailingPathDelimiter(Reg.ReadString('BinPath'));

if FileExists(FMagickPath + 'magick.exe') then
begin
Exit(True);
try
SearchPath := Reg.ReadString('LibPath');
if (SearchPath <> '') and FileExists(SearchPath + '\' + DllName) then
begin
if SearchPath[Length(SearchPath)] <> '\' then SearchPath := SearchPath + '\';
FMagickPath := SearchPath;
Result := True;
Exit;
end;
except
end;
end;
finally
Reg.Free;
end;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

SetEnvironmentVariable('MAGICK_HOME', PChar(FMagickPath));
SetEnvironmentVariable('MAGICK_CONFIGURE_PATH', PChar(FMagickPath));
SetEnvironmentVariable('MAGICK_CODER_MODULE_PATH', PChar(FMagickPath + 'modules\coders'));
SetEnvironmentVariable('MAGICK_FILTER_MODULE_PATH', PChar(FMagickPath + 'modules\filters'));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove filters.

FSupportedFormats.Clear;
FSupportedFormats.Delimiter := ',';
FSupportedFormats.StrictDelimiter := True;
FSupportedFormats.DelimitedText := 'bmp,gif,jpeg,jpg,png,tiff,webp,avif,heic,heif,jxl,ico,psd,svg,tga,jp2,raw,xcf,pcx,pgm,pbm,ppm,xpm,fax,g3,gif87';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limit the image format.

Comment thread baseunits/uBaseUnit.pas
Comment on lines +2395 to +2417
function ExtFromContentType(const ContentType: String): String;
var
FilePath, PathDirectory, FileExt: String;
ct: String;
begin
Result := '';
ct := LowerCase(Trim(ContentType));
if ct = '' then Exit;
if Pos('image/avif', ct) > 0 then Exit('avif');
if Pos('image/jxl', ct) > 0 then Exit('jxl');
if Pos('image/heic', ct) > 0 then Exit('heic');
if Pos('image/heif', ct) > 0 then Exit('heif');
if Pos('image/webp', ct) > 0 then Exit('webp');
if Pos('image/png', ct) > 0 then Exit('png');
if Pos('image/jpeg', ct) > 0 then Exit('jpg');
if Pos('image/gif', ct) > 0 then Exit('gif');
if Pos('image/bmp', ct) > 0 then Exit('bmp');
if Pos('image/tiff', ct) > 0 then Exit('tif');
if Pos('image/svg', ct) > 0 then Exit('svg');
if Pos('image/x-tga', ct) > 0 then Exit('tga');
if Pos('image/x-icon', ct) > 0 then Exit('ico');
if Pos('image/', ct) = 1 then
Result := Copy(ct, 7, Length(ct) - 6);
end;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce to just jpg, png, gif, bmp, tif, webp, avif, and jxl.

Comment thread baseunits/uBaseUnit.pas
Comment on lines +2807 to 2825
ext := LowerCase(ExtractFileExt(imgFileName));
case ext of
'.jpeg', '.jpg': Result := 'image/jpeg';
'.png': Result := 'image/png';
'.gif': Result := 'image/gif';
'.bmp': Result := 'image/bmp';
'.webp': Result := 'image/webp';
else Result := '';
'.tif', '.tiff': Result := 'image/tiff';
'.avif': Result := 'image/avif';
'.jxl': Result := 'image/jxl';
'.heic', '.heif': Result := 'image/heic';
'.j2k', '.jp2': Result := 'image/jp2';
'.svg': Result := 'image/svg+xml';
'.ico': Result := 'image/x-icon';
'.tga': Result := 'image/x-tga';
'.pcx': Result := 'image/x-pcx';
'.psd': Result := 'image/vnd.adobe.photoshop';
else Result := 'image/' + Copy(ext, 2, Length(ext) - 1);
end;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants